package com.xiao.xin.core.controller;

import com.xiao.xin.core.domain.QueryTasklist;
import com.xiao.xin.core.dto.CancelComfyuiTaskDto;
import com.xiao.xin.core.dto.Result;
import com.xiao.xin.core.dto.Text2ImageDto;
import com.xiao.xin.core.service.Text2ImageService;
import com.xiao.xin.core.vo.Text2ImageVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/***
 * 文生图接口
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/authed/1.0/t2i")
public class Text2ImageController {

    private final Text2ImageService text2ImageService;

    /***
     * 添加任务
     * @param dto
     * @return
     * @throws Exception
     */
    @PostMapping("/propmt")
    public Result<Text2ImageVo> propmt(@RequestBody Text2ImageDto dto) throws Exception {
        log.info("文生图:{}",dto);
       return Result.success(text2ImageService.propmt(dto));
    }

    /***
     * 分页查询任务
     * @param queryTasklist
     * @return
     */
    @PostMapping("/list")
    public Result list(@RequestBody QueryTasklist queryTasklist){
        Map mp = text2ImageService.list(queryTasklist);
        return Result.success(mp);
    }


    /***
     * 取消任务
     * @param cancelComfyuiTaskDto
     * @return
     */
    @PostMapping("/canel")
    public Result canel(@RequestBody CancelComfyuiTaskDto cancelComfyuiTaskDto){
        log.info("取消任务:{}",cancelComfyuiTaskDto);
        text2ImageService.cancel(cancelComfyuiTaskDto);
        return Result.success();
    }





}
